package com.therandoms.rtgdroid.background;

import java.util.ArrayList;
import java.util.List;

import org.therandoms.textgen.WordnikOptions;
import org.therandoms.textgen.WordnikPuller;

import com.wordnik.client.model.WordObject;

import android.os.AsyncTask;

public class WordnikLoaderAsyncTask extends
		AsyncTask<WordnikOptions, Integer, List<WordObject>> {

	@Override
	protected List<WordObject> doInBackground(WordnikOptions... params) {
		ArrayList<WordObject> words = new ArrayList<WordObject>();
		
		for (WordnikOptions option : params) {
			try {
				// try to load a result.
				words.addAll(WordnikPuller.addRandomWordnikResults(option));
			} catch (Exception e) {
				break;
			}
		}
		return words;
	}

}
